import axios from 'axios'
import qs from 'qs'

const instance = axios.create({
  baseURL: 'http://localhost:3000',
  timeout: 3000,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  }
})

const http = {
  post(url, data) {
    instance.post(url, { data: qs.stringify(data) }).then(res => res.data)
  },
  get(url, params) {
    instance.get(url, params).then(res => res.data)
  }
}
export default http
